import UIAbility from '@ohos.app.ability.UIAbility';
import hilog from '@ohos.hilog';
import window from '@ohos.window';

export default class DetailAbility extends UIAbility {

  localStorage:LocalStorage = new LocalStorage({'goodsId':0})

  onCreate(want, launchParam) {

    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
    //获取值
    let id=want?.parameters?.goodsId
    hilog.info(0x0000, 'testTag', '商品id%{public}s', `${id}`);
    this.localStorage.set('goodsId',id)


  }

  onDestroy() {
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
  }

  onWindowStageCreate(windowStage: window.WindowStage) {
    // Main window is created, set main page for this ability
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');

    windowStage.loadContent('pages/detail/GoodDetailPage',this.localStorage);
  }

  onWindowStageDestroy() {
    // Main window is destroyed, release UI related resources
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
  }

  onForeground() {
    // Ability has brought to foreground
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
  }

  onBackground() {
    // Ability has back to background
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
  }
}
